/*
 * Tomer Nuni 300585312
 * Idan Meshita 300043726
 */
import java.awt.Point;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.IOException;
import java.util.Collection;
import java.util.LinkedList;

/**
 * 
 * This class stores all the data about the scene - saving points in the real
 * world and edges between them.
 * 
 * @author Idan
 *
 */
public class SceneManager {

	private Point[] points ;
	private Collection<Edge> edges ;
	
	/**
	 * 
	 * This method initiate the scene manager by loading the points and edges
	 * form a file
	 * @param viewFileName 
	 * 
	 * @throws IOException
	 */
	public void init(String viewFileName) throws IOException {
		
		edges= new LinkedList<Edge>();
		
		BufferedReader r = new BufferedReader(new FileReader(viewFileName));
		loadPoints(r);
		loadEdges(r);
		
		r.close();
		

	}
	/**
	 * This method performs the loading of the points from the file
	 * 
	 * @param r - an open buffer to the file
	 * @throws IOException
	 */
	private void loadPoints(BufferedReader r) throws IOException{
		String line = r.readLine();
		int n = Integer.parseInt(line);
		
		points = new Point[n];
		for (int i = 0; i < n; i++) {
			
			line = r.readLine();
			String[] xy = line.split(" ");
			points[i]=new Point(Integer.parseInt(xy[0]), Integer.parseInt(xy[1]));
			
		}
	}	
	/**
	 * This method performs the loading of the edges from the file
	 * 
	 * @param r - an open buffer to the file
	 * @throws IOException
	 */
	private void loadEdges(BufferedReader r) throws IOException{
		String line = r.readLine();
		int n = Integer.parseInt(line);
		
		for (int i = 0; i < n; i++) {
			line = r.readLine();
			String[] fromTo = line.split(" ");
			edges.add(new Edge(Integer.parseInt(fromTo[0]), Integer.parseInt(fromTo[1])));
		}
	}
	/**
	 * 
	 * @return the points of the sence
	 */
	public Point[] getPoints() {
		return points;
	}


	/**
	 * 
	 * @return - collection of edges
	 */

	public Collection<Edge> getEdges() {
		return edges;
	}



}
